package com.fivefaces.ide.plugins.impl;

import com.fivefaces.ide.plugins.ConsoleExecutablePathService;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * User: imrank
 * Date: 13/04/11
 * Time: 11:19 AM
 */
public class MacCommandBuilder extends AbstractCommandBuilder {

    public MacCommandBuilder(ConsoleExecutablePathService consoleExecutablePathService) {
        super(consoleExecutablePathService);
    }

    protected FileWriter writeFile(String path, FileWriter fileWriter, File executeFile) throws IOException {
        fileWriter = new FileWriter(executeFile);
        fileWriter.write("#!/bin/sh\n");
        fileWriter.write("osascript -e 'tell application \"" + getExecutablePath() + "\"' -e \"do script \\\"cd " + path + "\\\"\" -e 'activate' -e 'end tell'");
        return fileWriter;
    }
}
